<?php
include ('../config.php');
//获取数据
//$sql="select * from admin ";
//$sql_result=$mysqli->query($sql);
//$row=$sql_result->fetch_array(MYSQLI_ASSOC);
if($input->get('do')=='chk'){
    $auser=$input->post('user');
    $apass=$input->post('pass');
    $sql="select * from admin WHERE auser='{$auser}' and apass='{$apass}'";
    $sql_result=$db->query($sql);
    $row=$sql_result->fetch_array(MYSQLI_ASSOC);
    if(is_array($row)){
        $_SESSION['aid']=$row['aid'];
        header('location:home.php');
        exit;
    }else{
        die('账号或密码错误！');
    }

}
?>

<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8" />
    <title>后台登录</title>
    <?php include (PATH.'/headr.php')?>
</head>
<body>
    <div class="container">
        <div class="row">
            <div class="col-md-6 col-md-offset-3">
                <div style="margin-top: 200px" class="panel panel-primary">
                    <div class="panel-heading">
                        <h3 class="panel-title">管理员登录</h3>
                    </div>
                    <div class="panel-body">
                        <form class="form-horizontal" action="login.php?do=chk" method="post">
                            <div class="form-group">
                                <label for="inputEmail3" class="col-sm-2 control-label">用户名</label>
                                <div class="col-sm-10">
                                    <input type="text" name="user" class="form-control" id="inputEmail3" placeholder="请输入用户名">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="inputEmail3" class="col-sm-2 control-label">密码</label>
                                <div class="col-sm-10">
                                    <input type="password" name="pass" class="form-control" id="inputEmail3" placeholder="请输入密码">
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-offset-2 col-sm-10">
                                    <button type="submit" class="btn btn-primary">提交登录</button>
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="panel-footer text-right">所有权版属于我</div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>